/*
题目地址:https://leetcode-cn.com/problems/power-of-three/
题目标签:数学
*/

class Solution {
   public:
    bool isPowerOfThree(int n) {
        while (n > 0 && n % 3 == 0) {
            n /= 3;
        }
        return n == 1;
    }
};